/*
 *
 *  Copyright 2017-2019 the original author or authors.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *
 */
package com.jingtai.validate.swagger;
//package springfox.springconfig;

import io.swagger.annotations.Example;
import io.swagger.annotations.ExampleProperty;
import com.jingtai.validate.validator.CApiParamValidator;
import org.springframework.stereotype.Component;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 兼容@ApiParam,并扩展Bean Validation 1.0 (JSR 303)规范
 * 
 * @author zhengchao
 * @date 2020年4月6日
 *
 */
@Target({ ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { CApiParamValidator.class })
public @interface CApiParam {

	String message() default "验证不合法";

	/**
	 * 自定义邮箱验证器
	 */
	boolean cEmail() default false;

	/**
	 * 自定义不为空验证器
	 */
	boolean cNotEmpty() default false;

	/**
	 * 自定义手机号码验证器
	 */
	boolean cPhone() default false;

	/**
	 * 自定义字符串长度最短验证器
	 */
	int cStrMinLen() default 0;

	/**
	 * 自定义字符串长度最长验证器
	 */
	int cStrMaxLen() default Integer.MAX_VALUE;

	/**
	 * 自定义整型最小值验证器
	 */
	int cIntMin() default Integer.MIN_VALUE;

	/**
	 * 自定义整型最大值验证器
	 */
	int cIntMax() default Integer.MAX_VALUE;

	/**
	 * 自定义正则验证器
	 */
	String cregexp() default "";

	Class<?>[] groups() default {};

	Class<? extends Payload>[] payload() default {};

	/**
	 * The parameter name.
	 * <p>
	 * The name of the parameter will be derived from the field/method/parameter
	 * name, however you can override it.
	 * <p>
	 * Path parameters must always be named as the path section they represent.
	 */
	String name() default "";

	/**
	 * 评论描述
	 */
	// String comment() default "";

	/**
	 * A brief description of the parameter.
	 */
	String value() default "";

	/**
	 * Describes the default value for the parameter.
	 * <p>
	 * If the parameter is annotated with JAX-RS's {@code @DefaultValue}, that value
	 * would be used, but can be overridden by setting this property.
	 */
	String defaultValue() default "";

	/**
	 * Limits the acceptable values for this parameter.
	 * <p>
	 * There are three ways to describe the allowable values:
	 * <ol>
	 * <li>To set a list of values, provide a comma-separated list. For example:
	 * {@code first, second, third}.</li>
	 * <li>To set a range of values, start the value with "range", and surrounding
	 * by square brackets include the minimum and maximum values, or round brackets
	 * for exclusive minimum and maximum values. For example: {@code range[1, 5]},
	 * {@code range(1, 5)}, {@code range[1, 5)}.</li>
	 * <li>To set a minimum/maximum value, use the same format for range but use
	 * "infinity" or "-infinity" as the second value. For example,
	 * {@code range[1, infinity]} means the minimum allowable value of this
	 * parameter is 1.</li>
	 * </ol>
	 */
	String allowableValues() default "";

	/**
	 * Specifies if the parameter is required or not.
	 * <p>
	 * Path parameters will always be set as required, whether you set this property
	 * or not.
	 */
	boolean required() default false;

	/**
	 * Allows for filtering a parameter from the API documentation.
	 * <p>
	 * See io.swagger.core.filter.SwaggerSpecFilter for further details.
	 */
	String access() default "";

	/**
	 * Specifies whether the parameter can accept multiple values by having multiple
	 * occurrences.
	 */
	boolean allowMultiple() default false;

	/**
	 * Hides the parameter from the list of parameters.
	 */
	boolean hidden() default false;

	/**
	 * a single example for non-body type parameters
	 *
	 * @since 1.5.4
	 *
	 * @return
	 */
	String example() default "";

	/**
	 * Examples for the parameter. Applies only to BodyParameters
	 *
	 * @since 1.5.4
	 *
	 * @return
	 */
	Example examples() default @Example(value = @ExampleProperty(mediaType = "", value = ""));

	/**
	 * Adds the ability to override the detected type
	 *
	 * @since 1.5.11
	 *
	 * @return
	 */
	String type() default "";

	/**
	 * Adds the ability to provide a custom format
	 *
	 * @since 1.5.11
	 *
	 * @return
	 */
	String format() default "";

	/**
	 * Adds the ability to set a format as empty
	 *
	 * @since 1.5.11
	 *
	 * @return
	 */
	boolean allowEmptyValue() default false;

	/**
	 * adds ability to be designated as read only.
	 *
	 * @since 1.5.11
	 *
	 */
	boolean readOnly() default false;

	/**
	 * adds ability to override collectionFormat with `array` types
	 *
	 * @since 1.5.11
	 *
	 */
	String collectionFormat() default "";



}
